<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../common/public_header_main.jsp"%>

<link href="${ctx_static }/dep/jedate/skin/jedate.css" rel="stylesheet">
<link rel="stylesheet" href="${ctx_static }/dep/chosen/css/chosen.css">
<link href="${ctx_static }/home/configuration/css/examSittings.css" rel="stylesheet">

<div class="row">
    <div class="col-lg-12 col-sm-12 col-xs-12">
        <div class="row">
            <div class="col-lg-12 col-sm-12 col-xs-12">
                <div class="widget">
                    <div class="widget-header">
                        <div class="widget-buttons">
                            <a href="#" data-toggle="collapse">
                                <i class="fa fa-minus"></i>
                            </a>
                            <a href="#" data-toggle="dispose">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                        <!--Widget Buttons-->
                    </div>
                    <!--Widget Header-->
                    <div class="widget-body">
                        <div class="widget-main ">
                            <div class="row row_padding form-horizontal">
                                <div class="col-lg-5 col-md-9 col-sm-9 col-xs-12">
                                    <div class="form-group col-lg-6 col-md-7 col-sm-7 no-margin-right">
                                        <input type="text" class="form-control" placeholder="考期/教育形式/项目/级别" id="searchVal" onkeydown="search();">
                                    </div>
                                    <div class="form-group col-lg-3 col-md-3 col-sm-3 no-margin-right">
                                        <select class="form-control" name="status" id="enable">
                                            <option value="">状态</option>
                                            <option value="0">禁用</option>
                                            <option value="1">启用</option>
                                        </select>

                                    </div>
                                    <div class="form-group col-lg-3 col-md-3 col-sm-3">
                                        <a type="button" class="btn btn-blue form-control search-btn" href="javascript:DataTable.init();"> 搜索
                                        </a>

                                    </div>
                                </div>
                                <div class="col-md-3 col-sm-3 col-xs-12 btn-group pull-right">
                                    <span class="btn btn-default pointer" title="View print view"><span>打印</span></span>
                                    <div class="btn-group">
                                        <button type="button" class="btn btn-default dropdown-toggle"
                                                data-toggle="dropdown">导出
                                            <i class="fa fa-angle-up"></i>
                                        </button>
                                        <ul class="dropdown-menu" role="menu">
                                            <li><a href="#">保存PDF</a></li>
                                            <li><a href="#">导出EXCEL</a></li>
                                            <li><a href="#">导出CSV</a></li>
                                        </ul>
                                    </div>
                                    <shiro:hasPermission name="bizExamSetting:add">
                                    <button class="btn increase pull-right col-sm-4" data-toggle="modal"
                                            data-target=".examinationAdd" data-backdrop="static">新增
                                        <i class="fa fa-plus-square-o right"></i></button>
                                    </shiro:hasPermission>    
                                </div>
                            </div>
                            <table class="table table-striped table-hover table-bordered dataTable no-footer" id="personnelMatch">
                                <thead>
                                <tr role="row">
                                    <th width="5%">
                                        <label>
                                            <input type="checkbox">
                                            <span class="text"></span>
                                        </label>
                                    </th>
                                    <th>考期 </th>
                                    <th>教育形式 </th>
                                    <th>项目 </th>
                                    <th>级别 </th>
                                    <th>状态 </th>
                                    <th>操作</th>
                                </tr>
                                </thead>

                                <tbody>
                                </tbody>
                            </table>

                        </div>

                    </div>

                </div>
            </div>

        </div>
    </div>
</div>
<!--新增-->
<div class="modal fade examinationAdd" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel"
     aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header bordered-blue">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <span class="widget-caption">新增</span>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="examinationAdd" method="post">
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">考试期次<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <input type="text" name="examDate" class="form-control form_datetime examDate">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">项目类别<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <select id="projectType" name="projectType" class="form-control projectType" onchange="selectProjectId()" required>
                            	<option value="">--请选择--</option>
                            	<option value="1">职业资格</option>
                                <option value="2">学历</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">项目<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <select id="projectId" name="projectId" class="form-control projectId chosen-select" onchange="selectProjectLiveId()" required>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">级别<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <select id="projectLevelId" name="projectLevelId" class="form-control projectLevelId" required>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">教育形式<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <select id="educationForm" name="educationForm" class="form-control educationForm" required>
                            	<option value="">--请选择--</option>
                                <option value="1">自考</option>
                                <option value="2">远程</option>
                                <option value="3">成考</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">预计禁用考期时间<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <div class="input-group">
                                <input class="form-control date-picker disabledDate" type="text" name="disabledDate">
                                <span class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">实际截止招生时间<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <div class="input-group">
                                <input class="form-control date-picker endDate" type="text" name="endDate">
                                <span class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">预计结费时间<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <div class="input-group">
                                <input class="form-control date-picker clearDate" type="text" name="clearDate">
                                <span class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group modal-footer">
                        <div class="col-sm-4 col-sm-offset-3">
                        	<button type="submit" class="btn btn-primary form-control">确定</button>
                        </div>
                        <div class="col-sm-4">
                            <button type="button" class="btn btn-danger form-control" data-dismiss="modal">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!--编辑-->
<div class="modal fade examinationEdit" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel"
     aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header bordered-blue">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <span class="widget-caption">编辑</span>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="examinationEdit" method="post">
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">考试期次<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <input type="hidden" id="updtexamSettingId" name="examSettingId" id="examSettingId" value="">
                            <input type="text" id="updtexamDate" name="examDate" class="form-control form_datetime examDate" value="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">项目类别<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                             <select name="projectType" id="updtprojectType" class="form-control projectType">
                                <option value="1">职业资格</option>
                                <option value="2">学历</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">项目<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <select name="projectId" id="updtprojectId" class="form-control updtprojectId chosen-select">
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">级别<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <select name="projectLevelId" id="updtprojectLevelId" class="form-control projectLevelId">
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">教育形式<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <select name="educationForm" id="updteducationForm" class="form-control educationForm">
                                <option value="1">自考</option>
                                <option value="2">远程</option>
                                <option value="3">成考</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">预计禁用考期时间<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <div class="input-group">
                                <input name="disabledDate" id="updtdisabledDate" class="form-control date-picker disabledDate" type="text" value="">
                                <span class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">实际截止招生时间<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <div class="input-group">
                                <input name = "endDate" id="updtendDate" class="form-control date-picker endDate" type="text" value="">
                                <span class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-4 no-padding-right">预计结费时间<span class="control-label mandatory">*</span></label>
                        <div class="col-sm-7">
                            <div class="input-group">
                                <input name="clearDate" id="updtclearDate" class="form-control date-picker clearDate" type="text" value="">
                                <span class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group modal-footer">
                        <div class="col-sm-4 col-sm-offset-3">
                        	<button type="submit" class="btn btn-primary form-control">确定</button>
                        </div>
                        <div class="col-sm-4">
                            <button type="button" class="btn btn-danger form-control" data-dismiss="modal">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!--日期插件-->
<script src="${ctx_static }/dep/jedate/jquery.jedate.min.js"></script>
<script src="${ctx_static }/dep/assets/js/datetime/bootstrap-datepicker.js"></script>

<script>
//考期初始化数据
var DataTable = function(){
	return{
		init: function(){
			var Table = $('#personnelMatch').dataTable({
				"bPaginate": true,  //是否显示分页
            	"iDisplayLength": 15,
            	"bLengthChange": false,//每页显示的记录数
            	"bFilter": false, //搜索栏
            	"bSort": true, //是否支持排序功能
            	"bInfo": true, //显示表格信息
            	"bAutoWidth": false,  //自适应宽度
            	"bStateSave": true, //保存状态到cookie *************** 很重要 ， 当搜索的时候页面一刷新会导致搜索的消失。使用这个属性就可避免了
            	//"sPaginationType": "", //分页，一共两种样式，full_numbers和two_button(默认)
            	"sAjaxSource" : ctx+'/bizExamSetting/load',
        		"fnServerData": retrieveData,//用于替换默认发到服务端的请求操作  
            	"bServerSide": true,
            	"bDestroy": true,
                "bRetrieve": false,
                "oLanguage" : {
        			"sLengthMenu" : "每页显示 _MENU_ 条记录",
        			"sZeroRecords" : "抱歉， 没有找到",
        			"sInfo" : "从 _START_ 到 _END_ / 共 _TOTAL_ 条数据",
        			"sInfoEmpty" : "找不到相关数据",
        			"sInfoFiltered" : "数据表中共为 _MAX_ 条记录)",
        			"sProcessing": "正在加载中...",
        			"sSearch": "搜索",
        			"oPaginate" : {
        				"sFirst" : "首页",
        				"sPrevious" : "前一页",
        				"sNext" : "后一页",
        				"sLast" : "尾页"
        			},
        		},
        		"aoColumns" : [
          			            {
          			                "mData": "examSettingId", 'sClass': "text-center", "bSortable": false, "mRender": function (data, type, full) {
          			                return '<label  class="labletab" style="padding-top: 0px"> <input name="ajaxcheckbox" type="checkbox" class="checkchild"> <span class="text" ></span> </label>';
          			            }
          			            },
//          			            {"mData": "examDate", 'sClass': "hiddenCol"},
          			            {"mData": "examDate", 'sClass': "text-center"},
          			            {"mData": "educationForm", 'sClass': "text-center"},
          			            {"mData": "bizProject.fullName", 'sClass': "text-center"},
          			            {"mData": "bizProjectLevel.levelTitle", 'sClass': "text-center"},
          			            {"mData": "enable", 'sClass': "text-center","bSortable": false,"mRender":function(data, type, full ){
          			            	if(data==0){
          			          		  return '<span id="span'+full["examSettingId"]+'" onclick="chooseStudent(\''+full["examSettingId"]+'\')" class="btn btn-xs btn-nouse"><i class="fa fa-ban"></i> 禁用</span>';
          			          	  }else{
          			          		  return '<span id="span'+full["examSettingId"]+'" onclick="chooseStudent(\''+full["examSettingId"]+'\')" class="btn btn-xs btn-use"><i class="fa fa-check-circle-o"></i> 启用</span>';
          			          	  }
          			            }},
          			            {
          			                "mData": "examSettingId",
          			                'sClass': "text-center",
          			                "bSortable": false,
          			                "mRender": function (data, type, full ) {
          			                    var u = '<shiro:hasPermission name="bizExamSetting:edit"><a onclick="edit(\''+full["examSettingId"]
          			                    	+'\',\''+full["examDate"]
          			                    	+'\',\''+full["projectType"]	
	          			                    +'\',\''+full["projectId"]
          			                    	+'\',\''+full["projectLevelId"]
          			                    	+'\',\''+full["educationForm"]
	          								+'\',\''+full["disabledDate"]
	          								+'\',\''+full["endDate"]
	          								+'\',\''+full["clearDate"]
          			                    	+'\')"class="btn btn-info btn-xs edit" data-toggle="modal" data-target=".examinationEdit" data-backdrop="static" '+(full.enable == 0 ? "disabled" : "")+'><i class="fa fa-edit"></i> 编辑</a></shiro:hasPermission>';
          			                	return u;
          			                }
          			            }
          			        ],
          			      "aoColumnDefs": [{
       		   	            sDefaultContent: '',
       		   	            aTargets: ['_all']
       		   	        }],
	       		   	  "fnRowCallback":function(nRow,aData,iDisplayIndex){
			   	        	if(aData.educationForm=='1'){
			   	        		$('td:eq(2)',nRow).html('自考');
			   	        	}else if(aData.educationForm=='2'){
			   	        		$('td:eq(2)',nRow).html('远程');
			   	        	}else if(aData.educationForm=='3'){
			   	        		$('td:eq(2)',nRow).html('成考');
			   	        	}
			   	        	return nRow;
			   	        },
			})
		}
	}
}();

</script>

<script src="${ctx_static }/dep/chosen/js/chosen.jquery.js"></script>
<script src="${ctx_static }/home/configuration/js/examSittings.js"></script>
